1 /* JJT: 0.2.2 */
2
3 package mobisnap.mobile_trx;
4
5 import java.util.*;
6
7 /***
8 * Implements multiplicative expression
9 */
10 public class ASTPlSqlMultiplicativeExpression extends mobisnap.mobile_trx.SimpleNode {
11 public static final byte OP_MULTI = 0;
12 public static final byte OP_DIVI = 1;
13
14 public ASTPlSqlExpotentExpression first;
15 public Vector ands;
16
17 public ASTPlSqlMultiplicativeExpression(int id) {
18 super(id);
19 ands = new Vector();
20 }
21
22 public ASTPlSqlMultiplicativeExpression( MobisnapSQL p, int i) {
23 super( p, i);
24 id = i;
25 ands = new Vector();
26 }
27
28 /*** Accept the visitor. **/
29 public Object jjtAccept(MobisnapSQLVisitor visitor, Object data) {
30 return visitor.visit(this, data);
31 }
32
33 public class term {
34 public byte opType;
35 public ASTPlSqlExpotentExpression expr;
36
37 public term( byte opType, ASTPlSqlExpotentExpression expr) {
38 this.opType = opType;
39 this.expr = expr;
40 }
41 };
42
43 public void insert( byte opType, ASTPlSqlExpotentExpression expr) {
44 ands.addElement( new term( opType, expr));
45 }
46
47 /***
48 * Returns the value of the expression
49 *
50 * @param msql_type Specifies which type of processing should be performed
51 * MobisnapConstants.MSQL_SERVER = 1
52 * MobisnapConstants.MSQL_TENTATIVE_CLIENT = 2
53 * MobisnapConstants.MSQL_STABLE_CLIENT = 3
54 * MobisnapConstants.MSQL_RESERVATION_CLIENT = 4
55 * @param cond True if reservations associated iwth transaction should be
56 * propagated to the current transaction
57 */
58 public Object value( int msql_type, boolean cond) throws Exception {
59 Object val = first.value( msql_type, cond);
60 for( int i = 0; i < ands.size(); i++) {
61 term t = (term)ands.elementAt( i);
62 if( t.opType == OP_MULTI)
63 val = MSQLTypeUtil.multiply( val, t.expr.value( msql_type, cond));
64 else
65 val = MSQLTypeUtil.divide( val, t.expr.value( msql_type, cond));
66 }
67 return val;
68 }
69
70 }
This page was automatically generated by Maven